#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
from functools import wraps

check_auth = {"user": None}


def check_auth_types(auth_type="file"):
    def auth(func):
        # @wraps(func)
        def wrapper(*args, **kwargs):
            if check_auth["user"]:
                res = func(*args, **kwargs)
                return res
            if auth_type == "file":
                print("文件认证")
                user = input("username >>>: ").strip()
                passwd = input("passwd >>>: ").strip()
                if user == "xiong" and passwd == "123":
                    res = func(*args, **kwargs)
                    return res
            if auth_type == "mysql":
                return func(*args, **kwargs),"数据库认证"
            return "登陆失败"

        return wrapper

    return auth


# x = check_auth_types(auth_type="mysql")

@check_auth_types(auth_type="mysql")  # 也可以是 @x
def login():
    return "登陆到了主页"


print(login())
